#include <iostream>
using namespace std;

int main()
{
	int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
	int n = 0;
	int a[4] = {0,0,0,0};
	int count = 0;
	for (int i = 1; i <= 12; i++)
	{
		for (int j = 1; j <= days[n]; j++)
		{
			a[0] = i/10;
			a[1] = i%10;
			a[2] = j/10;
			a[3] = j%10;
			cout << a[0] << a[1] << a[2] << a[3] << endl; 
			if ((a[1] == a[0]+1 && a[2] == a[1]+1) || (a[2] == a[1]+1 && a[3] == a[2]+1))
			{
				count++;
			}
		}
		n++;
	}
	cout << count << endl;
	return 0;
}
